package GameMain.View.GameErea
{
	import Engine.Module.ModuleBase;
	
	import GameMain.Game;
	import GameMain.Macro.Macro;
	import GameMain.Macro.MacroEvent;
	import GameMain.Macro.MacroSound;
	import GameMain.UIControl.HallButton;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	
	import library.SocketData.SocketData;
	
	
	public class GameErea extends ModuleBase
	{
		private static var FRAME_END:int = 13;
		private static var FRAME_CHURCH:int = 1;
		private static var FRAME_SHOP:int = 2;
		private static var FRAME_dungeon:int = 3;
		private static var FRAME_roomList:int = 4;
		private static var FRAME_auction:int = 5;
		private static var FRAME_active:int = 6;
		private static var FRAME_civil:int = 7;
		private static var FRAME_store:int = 8;
		private static var FRAME_campaignLab:int = 9;
		private static var FRAME_tofflist:int = 10;
		private static var FRAME_hotWell:int = 11;
		private static var FRAME_consortia:int = 12;
		
		private var _p_mc:MovieClip = null;
		
		public function GameErea(p_content:Sprite)
		{
			super(p_content);
			this._p_mc = this._content as MovieClip;
			this._p_mc.x = -331;
			this._p_mc.y = -336;
			this._p_mc.gotoAndStop(FRAME_END);
			this.initUI();
			Game.EngineMgr.registerEvent(MacroEvent.MSG_FROM_SERVER_RETURN_AREA,onShowThis);
		}
		
		
		private function initUI():void
		{
			var btn:HallButton = new HallButton(this._content["church_mc"]);
			btn.setOnClickParam(FRAME_CHURCH);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["shop_mc"]);
			btn.setOnClickParam(FRAME_SHOP);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["dungeon_mc"]);
			btn.setOnClickParam(FRAME_dungeon);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["roomList_mc"]);
			btn.setOnClickParam(FRAME_roomList);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["auction_mc"]);
			btn.setOnClickParam(FRAME_auction);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["active_mc"]);
			btn.setOnClickParam(FRAME_active);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["civil_mc"]);
			btn.setOnClickParam(FRAME_civil);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["store_mc"]);
			btn.setOnClickParam(FRAME_store);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["campaignLab_mc"]);
			btn.setOnClickParam(FRAME_campaignLab);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["tofflist_mc"]);
			btn.setOnClickParam(FRAME_tofflist);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["hotWell_mc"]);
			btn.setOnClickParam(FRAME_hotWell);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
			btn = new HallButton(this._content["consortia_mc"]);
			btn.setOnClickParam(FRAME_consortia);
			btn.setEnterFun(onEnterFun);
			btn.setOnClickFun(onClickFun);
			
		}
		
		private function onShowThis(data:SocketData):void
		{
			Game.ModuleMgr.showGameErea();
		}
		
		private function onEnterFun(index:int):void
		{
			this._p_mc.gotoAndStop(index);
		}
		
		private function onClickFun(index:int):void
		{
			switch(index)
			{
				case FRAME_roomList:
					Game.ModuleMgr.showRoomList();
					break;
				case FRAME_dungeon:
					Game.ModuleMgr.showModule(Macro.MODULE_FUBEN);
					break;
				case FRAME_campaignLab:
					Game.EntityMgr.startNewPlayerTeach();
					break;
			}
		}
		
		protected override function onShowBack():void
		{
			//Game.soundMgr.soundPlay(MacroSound.SOUND_GAME_EREA);
			this._p_mc.gotoAndStop(FRAME_END);
		}
		
		
		protected override function onDisposeBack():void
		{
			//Game.soundMgr.soundClose(MacroSound.SOUND_GAME_EREA);
		}
	}
}